<include file="Member:leftmenu" />
<div class="content-right fl">
    <h1 class="content-right-title">申请列表</h1>

    <div class="tablesWrap">
        <div class="tabs clearfix mgt10">
            <a href="/admin/member/apply" class="<?php echo (!isset($_GET['status']))?'active':'';?> tabs_a fl">全部</a>
            <a href="/admin/member/apply?status=0" class="<?php echo (isset($_GET['status']))&&$_GET['status']==0?'active':'';?> tabs_a fl">待审核</a>
            <a href="/admin/member/apply?status=1" class="<?php echo ($_GET['status']==1)?'active':'';?> tabs_a fl">已通过</a>
            <a href="/admin/member/apply?status=2" class="<?php echo ($_GET['status']==2)?'active':'';?> tabs_a fl">已拒绝</a>
        </div>
        <div>
    </div>


    <!-- end tables-searchbox -->
    <table class="wxtables" style="margin-top:10px;">
        <colgroup>
            <col width="6%">
            <col width="6%">
            <col width="8%">
            <col width="6%">
            <col width="6%">
            <col width="6%">
        </colgroup>
        <thead>
            <tr>
                <td>用户信息</td>
                <td>类型</td>
                <td>地区信息</td>
                <td>申请时间</td>
                <td>状态</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>

            <foreach name="datalist" item="vo">
                <tr>
                    <td>
                        用户ID:{$vo['member']['uid']}<br>
                        用户姓名:{$vo['member']['realname']}<br>
                    </td>
                    <td>
                        <?php if($vo['type']==1) { ?>
                            地区代理
                        <?php } ?>
                        <?php if($vo['type']==2) { ?>
                            加盟商
                        <?php } ?>
                    </td>
                    <td>
                        {$vo['area']['all_name']}<br>
                    </td>
                    <td>
                        {$vo['create_time']}
                    </td>
                    <td>
                        <?php if($vo['status']==0) { ?>
                            待审核
                        <?php } ?>
                        <?php if($vo['status']==1) { ?>
                            审核通过<br>
                            {$vo['shenhe_time']}<br>
                            管理员:{$vo['shenhe_username']}<br>
                        <?php } ?>
                        <?php if($vo['status']==2) { ?>
                            已拒绝<br>
                            原因:{$vo['note']}<br>
                        <?php } ?>
                    </td>
                    <td>
                        <?php if($vo['status']==0) { ?>
                            <a onclick="shenhe({$vo['id']},1)" class="btn btn-success btn-small" >通过</a>
                            <a onclick="shenhe({$vo['id']},2)"  class="btn btn-danger btn-small" >拒绝</a>
                        <?php } ?>
                    </td>
                </tr>
            </foreach>
        </tbody>
    </table>

    <div class="tables-btmctrl clearfix">
        <div class="mgt10">
            <div class="paginate">
                {$page}
            </div>
        </div>
    </div>
</div>
<script src="https://cdn.bootcss.com/layer/3.1.0/layer.js"></script>
<script>
    function shenhe (id,status) {
        if(status==2) {
            layer.prompt({title: '请输入拒绝原因', formType: 2}, function(text, index){
                $.ajax({
                    url:'/admin/member/shenheApply',
                    data: {
                        status: status,
                        id: id,
                        note: text
                    },
                    type:'post'
                }).then(function(res){
                    layer.close(index);
                    if(res.ret==1) {
                        layer.msg(res.msg, { icon: 2 },function(){
                            location.reload();
                        });
                    }else{
                        layer.msg(res.msg, { icon: 1 },function(){
                            location.reload();
                        });
                    }
                })
            });
        }else if(status==1){
            layer.confirm('确定审核通过吗?', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.ajax({
                    url:'/admin/member/shenheApply',
                    data: {
                        status: status,
                        id: id
                    },
                    type:'post'
                }).then(function(res){
                    if(res.ret==1) {
                        layer.msg(res.msg, { icon: 2 },function(){
                            location.reload();
                        });
                    }else{
                        layer.msg(res.msg, { icon: 1 },function(){
                            location.reload();
                        });
                    }
                })
                
            }, function () {
               
            });
        }
        
    }
</script>